﻿<?php
 $this->Html->scriptStart(array('inline'=>false));
 ?>

(function($){ //コレで囲む

	$(function(){
		var availableTags = [
	      "にんじん",
	      "豆乳",
	      "パプリカ",
	      "プリン",
	      "シチュー",
	      "おつまみ",
	      "ビール",
	      "鍋",
	      "小麦粉",
	      "生姜",
	      "大根",
    	];
		$( "#tags" ).autocomplete({
    	  source: availableTags
   		});

   		$("tr:nth-child(even)").addClass("treven");

    	$("tr:not(:first-child)").mouseover(function(){
    		$(this).addClass("trhover");
  	 	 }).mouseout(function(){
  	 	 	$(this).removeClass("trhover");
  	 	 });
	});

	function readPatternFile($file){
        $data = array();
        require_once($file);
        if(count($data) != 0){
            return $data;
        }else{
            return $reply_pattern;
        }
    }

}(jQuery)); //コレで囲む

<?php $this->Html->scriptEnd(); ?>

<h2>レシピリンク集</h2>

<form action="Links" method="post">
<input id="tags" name="tags" value="<?=isset($tags)?$tags:""?>">
<input type="submit" name="submit">
</form>

<table>
<th>No.</th>
<th>レシピ名</th>
<th>掲載元</th>

<?php
	$cnt=0;
	foreach($linkData as $data):
	$cnt++;
?>

<!-- h():htmlspecialchar() -->

<tr>
<td><?php echo $cnt; ?></td>
<td><?php echo $this->Html->link(h($data['Link']['l_name']),h($data['Link']['l_url']),array('target'=>'_blank')); ?></td>

<td><?php echo nl2br(h($data['Link']['l_site'])); ?></td>
<td>
<?php
	echo $this->Html->link('編集',array('action'=>'edit',$data['Link']['id']));
?>

<?php
	echo $this->Html->link('削除',array('action'=>'delete',$data['Link']['id']));
?>
</tr>

<?php endforeach; ?>

</table>